import requests
import json

# get请求
response = requests.get("https://www.baidu.com")
print(response.text)
print(response.ok)
print(response.encoding)
print(response.url)

# payload = {'wd': 'python'}
# response = requests.get("http://www.baidu.com/s?", params=payload)
# print(response.text)
# print(response.url)

# post请求
payload = {'key1': 'value1', 'key2': 'value2'}
response = requests.post('http://httpbin.org/post', data=payload)
print(response.text)
print(response.url)

payload = {'some': 'data'}
headers = {'content-type': 'application/json'}
response = requests.post("https://api.github.com/some/endpoint", data=json.dumps(payload), headers=headers)
print(response.text)
print(response.url)